package com.button.springboothdfsclient.conf;

import org.apache.hadoop.fs.FileSystem;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @Description
 * @Author Administrator
 * @Date 2023/2/2 11:52
 **/
@Configuration
public class HdfsFilesystemConf {

    @Value("${hdfs.defaultFs}")
    private String defaultFS;

    @Bean
    public FileSystem hdfsFileSystem() throws IOException {
        org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
        configuration.set("fs.defaultFS", defaultFS);
        return FileSystem.get(configuration);
    }
}
